<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-02 19:42:06
 * @LastEditTime: 2023-07-02 13:49:15
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 
 */

namespace App\Repositories;

use App\Models\CompanyCategory;
use Illuminate\Support\Facades\DB;

class CompanyCategoryRepository extends Repositories
    {


    public function __construct(CompanyCategory $model)
        {
        $this->model = $model;
        }

    public function list()
        {
        $list = $this->condition()->with(["children", 'finance', 'department'])->get();
        return $list;
        }

    public function delete($ids)
        {
        return treeListCallBack(
            $this->model
                ->with(['children'])
                ->whereIn("id", $ids)
                ->get(),
            function ($model)
                {
                $model->delete();
                return $model;
                }
        );
        }
    }